package com.chixing.controller;


import com.chixing.entity.Coupon;
import com.chixing.entity.Dish;
import com.chixing.entity.Mycoupon;
import com.chixing.service.IMycouponService;
import com.chixing.service.impl.MycouponServiceImpl;
import com.chixing.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.time.LocalDateTime;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2025-05-21
 */
@RestController
@RequestMapping("/mycoupon")
public class MycouponController {
    @Autowired
    private IMycouponService mycouponService;
    @GetMapping("/status/{status}")
    public Result getAll(@PathVariable Integer status){
        Result result = mycouponService.getAll(status);
        return result;
    }
    @PostMapping
    public Result save(@RequestBody Mycoupon coupon){
        coupon.setMycouponCreateDate(LocalDateTime.now());
        coupon.setStatus(0);
        return mycouponService.save(coupon);
    }
}
